<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use DB;
// use Hash;
// use App\Http\Requests\IndexController;

class IndexController extends Controller
{
    //主页展示
    public function index(Request $request)
    {

        //热播电影
    	$video = DB::table('video')
            ->join('type', 'video.tid', '=', 'type.id')
            ->where('video.id','=','1 && type.id = 1' )
            ->first();
            // dd($video);

    	 //获取数据电影
        $videos = DB::table('video')
                ->where('tid','1')
                ->orderBy('video.click', 'desc')
                ->paginate(6);

       

        //热播电视剧
        $tv = DB::table('video')
            ->join('type','video.tid', '=', 'type.id')
            ->where('video.tid','=','2')
            ->first();
            
        //获取数据电视剧
        $tvs = DB::table('video')
                ->where('tid','2')
                ->orderBy('video.click', 'desc')
                ->paginate(6);

        //热播动漫
        $comic = DB::table('video')
            ->join('type','video.tid', '=', 'type.id')
            ->where('video.tid','=','3')
            ->first();
            
        //获取数据动漫
        $comics = DB::table('video')
                ->where('tid','3')
                ->orderBy('video.click', 'desc')
                ->paginate(6);

        //热播原创
        $original = DB::table('video')
            ->join('type','video.tid', '=', 'type.id')
            ->where('video.tid','=','4')
            ->first();
            
        //获取数据原创
        $originals = DB::table('video')
                ->where('tid','4')
                ->orderBy('video.click', 'desc')
                ->paginate(6);
      

    	$ad = DB::table('ad')->first();
    		//解析模板
    		return view('home.index',['video'=>$video,'videos'=>$videos,'tv'=>$tv,'tvs'=>$tvs,'ad'=>$ad,'comic'=>$comic,'comics'=>$comics,'original'=>$original,'originals'=>$originals]);
    	
    	
    }
}
